﻿/**
 *	(C) 2014 Yuanjj
 *
 *	define net work protocal thread class
 *
 *	histroy
 * 		2014-08-07	yuanjj	- create the file
 */

#include "net_thread.h"
#include "errorcode.h"
#include "routine/global.h"
#include "routine/protocal/protocal.h"

net_thread::net_thread()
{
    m_tunnel	= CL_NET;
    m_main		= MAIN_NET;
}

net_thread::~net_thread()
{
}

/**
 *	deal protocal recv from the net tunnel
 *
 * 	@pdata			[in] the protocal buffer
 * 	@size			[in] the buffer size
 *
 * 	return
 * 		==	PEM_OK		protocal is good
 * 		!=	PEM_OK		errorcode
 */
pem_error_t net_thread::deal_protocal( pem_s8_t* pdata, pem_u32_t size )
{
    pem_error_t		res;
    head_in&		head = *(head_in*)pdata;

    res = base_thread::deal_protocal( pdata, size );
    if ( PEM_OK != res )
        return res;

    switch ( head.second )
    {
    case 0:
        break;
    default:
        res = BUILD_ERRORCODE( 0, PEM_PROTOCAL_UNKNOW );
        g_log.write( LOG_WARN, "net protocal", "Unknow protocal second(%d)", head.second );
        break;
    }

    return	res;
}
